
import axios from '@/request';

// 获取最新文章
export const getArticleList = () => {
  return axios.get('/api/article?page=1&pageSize=6');
};

// 获取评论
export const getCommentsList = () => {

  return axios.get('/api/comment?page=1&pageSize=6')
}

// 修改评论状态
export const changeComments = (id: string, pass: boolean) => {
  return axios.patch(`/api/comment/${id}`, {
      pass
  })
}
//删除评论
export const delComments = (id: string,) => {
  return axios.delete(`/api/comment/${id}`)
}
// 添加评论
export const addComments = (obj:any)=>{
  return axios.post(`/api/comment`, {
    ...obj
})
}
// https://bjwz.bwie.com/wipi/api/comment/f4dbfe37-679e-40a3-a495-a271d6d8cbfb

// 获取所有文章
export const getArticlesList = (params: any) => {
  return axios.get('/api/article', {
      params
  })
}

// 获取分类
export const getcategory = () => {
  return axios.get('/api/category')
}
// 获取标签
export const gettag = () => {
  return axios.get('/api/tag')
}
// 修改首焦状态
export const changeFocus = (id: string, isRecommended: boolean) => {
  return axios.patch(`/api/article/${id}`, {
    isRecommended
  })
}
// 修改状态
export const changeStatu = (id: string, status: string) => {
  return axios.patch(`/api/article/${id}`, {
    status
  })
}
//删除文章
export const delArticles = (id: string,) => {
  return axios.delete(`/api/article/${id}`)
}
// 获取详情
export const getDetailInfo = (id: string) => {
  return axios.get(`/api/article/${id}`)
}

//添加标签
export const tag_add = (obj:any)=>{
  console.log(obj)
  return axios.post(`/api/tag`, {
    ...obj
})
}
// 删除标签
export const tag_del = (id: string,) => {
  return axios.delete(`/api/tag/${id}`)
}
//添加分类
export const category_add = (obj:any)=>{
  console.log(obj)
  return axios.post(`/api/category`, {
    ...obj
})
}
// 删除分类
export const category_del = (id: string,) => {
  return axios.delete(`/api/category/${id}`)
}
//https://bjwz.bwie.com/wipi/api/comment?page=1&pageSize=6
// https://bjwz.bwie.com/wipi/api/category
// https://bjwz.bwie.com/wipi/api/tag
// https://bjwz.bwie.com/wipi/api/article/3bafda69-d242-4031-9659-417ab3fac38a
//https://bjwz.bwie.com/wipi/api/comment?page=1&pageSize=6

